﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using SimpleScrum.Objects;

namespace SimpleScrum.Helpers
{
    public class EnumHelper
    {
        public static EnumInfo GetEnumInfo(int i, Type eType)
        {
            return new EnumInfo()
            {
                
                ID = i,
                Name = Enum.GetName(eType, i)
            };
        }


        public static EnumInfo GetEnumInfo(object i, Type eType)
        {
            return new EnumInfo()
            {
             
                ID = Convert.ToInt32(i),
                Name = Enum.GetName(eType, i)
            };
        }

        public static List<EnumInfo> GetEnumInfo(Type enumType)
        {
            var enums = new List<EnumInfo>();

            if (!enumType.IsEnum)
                return enums;

            enums.AddRange(from object v in Enum.GetValues(enumType)
                           select new EnumInfo()
                                      {
                                          ID = (int) v, Name = Enum.GetName(enumType, v)
                                      });

            return enums;
        }
    }
}